import java.util.Scanner;

import javax.swing.plaf.synth.SynthOptionPaneUI;

public class hk5Q2 
{
    public static void main(String[] args) 
    {
        Scanner input = new Scanner(System.in);
        System.out.println("Please enter the number of the students.");
        int student = input.nextInt();
        Scanner nameload = new Scanner(System.in);
        String[] name = new String[student];
        double[][] score = new double[student][4];
        for (int i = 0; i < student; i++) 
        {
            System.out.println("please enter the No." + (i + 1) + "'s name. " + "\t");
            name[i] = nameload.nextLine();
            System.out.println("please load in the Chinese score. " + "\t");
            score[i][1] = input.nextInt();
            System.out.println("please load in the Math score. " + "\t");
            score[i][2] = input.nextInt();
            System.out.println("please load in the English score. " + "\t");
            score[i][3] = input.nextInt();
        }
        float[] averageSTU = new float[student];
        int[] sumSTU = new int[student];
        for (int i = 0; i < student; i++) 
        {
            for (int j = 1; j < score[i].length; j++) 
            {
                sumSTU[i] += score[i][j];
                averageSTU[i] = sumSTU[i] / 3;
            }
            System.out.println("NAME" + "\t" + "CHINESE" + "\t" + "MATH" + "\t" + "ENGLISH" + "\t" + "AVERAGE" + "\t");
            System.out.print(name[i] + "\t" + score[i][1] + "\t" + score[i][2] + "\t" + score[i][3] + "\t"
                    + String.format("%.2f",averageSTU[i]) + "\t");
            System.out.println();
        }
        System.out.println("-------------------------------------------");
        System.out.print("Average" + "\t");
        int i;
        float[] averageSUB = new float[4];
        for (int j = 1; j < 4; j++) 
        {
            float sumSUB = 0;
            for (i = 0; i < student; i++)
            {

                sumSUB += score[i][j];
            }
            averageSUB[j] = sumSUB / student;
            System.out.print(String.format("%.2f",averageSUB[j]) + "\t");
        }
        input.close();
    }
} 
